<div id="bonus-modal" style="top: 20%;" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <form action="<?php echo getUrl('merchant/saveBonus');?>" class="form-horizontal" id="bonus-form" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">广告图<span class="required">*</span></label>
                        <div class="col-md-6">
                            <div class="fileinput fileinput-new" data-provides="fileinput"><input type="hidden">
                                <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px; line-height: 140px;">
                                    <img src="" />
                                </div>
                                <div>
                                    <span class="btn default btn-file">
                                        <span class="fileinput-new">选择图片</span>
                                            <span class="fileinput-exists">改变</span>
                                        <input name="pic" type="file">
                                    </span>
                                    <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">删除</a>
                                </div>
                            </div>
                            <div class="clearfix margin-top-10">
                                <span>
                                    <i class="fa fa-exclamation-triangle"></i>
                                </span>
                                图片格式：gif,png,jpg;大小:2MB
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">发放数量<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required number" name="amount" type="text" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">开始时间<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required" name="start_time" dp type="text" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">结束时间<span class="required">*</span></label>
                        <div class="col-md-9">
                            <input class="form-control required" name="end_time" dp type="text" value="">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="merchant_id" value="">
                    <input type="hidden" name="id" value="">
                    <button class="btn green">保存</button>
                    <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>

                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var model = $('#bonus-modal');
        $('.edit-btn').live('click', function(){
            var url = $(this).attr('href');
            l_blockUI();
            $.ajax(url, {
                dataType:'json',
                type:'get',
                error:function(){
                    show_message({status:0, info:'请求超时'});
                    App.unblockUI();
                },
                timeout:60000,
                success:function(data,textStatus,jqXHR){
                    if(!data){
                        show_message({status:0, info:'请求超时'});
                        return;
                    }

                    model.find('.modal-title').html('编辑红包' );
                    model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                    model.find('.show_message_error').remove();
                    for(var k in data){
                        if(k == 'pic'){
                            model.find('.fileinput-preview img').attr('src', data[k]['sm']);
                        }
                        else{
                            model.find('[name="'+k+'"]').val(data[k]);
                        }
                    }

                    model.modal();
                    App.unblockUI();
                }
            });

            return false;
        });


        $.e_validate.init('#bonus-form',{modal:model,ignore:'',successCallback:function(data){
            $('#datatable_bonus').dataTable().fnDraw();
        }});

        $('[dp]').not("[noinit]").datepicker({
            changeMonth: true,
            autoclose: true,
            format: "yyyy-mm-dd",
            language: 'zh-CN'
        });


    });
   
</script>